<template>
  <div class="reportFormPage">
    <div id="domid" class="report-dom">
      <el-row>
        <el-col :span="5" :offset="19">
          <div class="pageNumBox">
       <span>第</span>
       <span class="placeholder-min text-center">&nbsp;{{ form.page }}&nbsp;</span>
       <span>页，共</span>
       <span class="placeholder-min text-center">&nbsp;{{ form.totalPage }}&nbsp;</span>
       <span>页</span>
     </div>
        </el-col>
      </el-row>
      <div class="topTwoBox">
        <div class="centerName">混凝土抗压弹性模量试验检测记录表（棱柱体）</div>
        <div class="codeText">
          <tr>BGLQ05002F</tr>
        </div>
      </div>
      <div class="threeTopBox">
        <div class="left-border">
          <div class="box-title">检测单位名称：</div>
          <div class>{{ form.jiancdwmc }}</div>
        </div>
        <div class="right-border">
          <span>记录编号：</span>
          <span class="placeholder">{{ form.jilbh }}</span>
        </div>
      </div>
      <!-- .........................1111111111111111111111111111111......................................................... -->
      <div class="table-border">
      <table height="220px" class="top-table">
        <tbody>
          <tr>
            <td align="center" width="15%" height="25">
              <span style="width:90px;display:inline-block">工程名称</span>
            </td>
            <td width="85%" class="text-center" colspan="3">
              <span>{{ form.gongcmc }}</span>
            </td>
          </tr>
          <tr>
            <td align="center" width="15%" height="25">
              <span style="width: 90px; display: inline-block">工程部位/用途</span>
            </td>
            <td width="85%" class="text-center" colspan="3">
              <span>{{ form.gongcbwyt }}</span>
            </td>
          </tr>
          <tr>
            <td height="50" align="center">样品信息</td>
            <td class="specimen-border" colspan="3">
                <span>样品名称：</span>
                <span :class="{ 'placeholder':!form.yangpmc }">{{ form.yangpmc }}</span>
                <span>；样品编号：</span>
                <span  :class="{ 'placeholder-long':!form.yangpbh }">{{ form.yangpbh }}</span>
                <span>；样品数量：</span>
                <span :class="{ 'placeholder':!form.yangpsl }">{{ form.yangpsl }}</span>
                <span>；样品状态：</span>
                <span :class="{ 'placeholder':!form.yangpzt }">{{ form.yangpzt }}</span>
                <span>；来样时间：</span>
                <span :class="{ 'placeholder':!form.yangpsj }">{{ form.yangpsj }}</span>
              </td>
          </tr>
          <tr>
            <td height="25" align="center" width="15%">
              <span style="width: 90px; display: inline-block">试验检测日期</span>
            </td>
             <!-- <td width="35%" class="text-center">{{ form.shiyjcrq }}</td> -->                                            
 <td width="35%" class="text-center">
      <el-input v-model="form.shiyjcrq" />
</td>

            <td align="center" style="width:15%">
              <span style="width: 90px; display: inline-block">试验条件</span>
            </td>
            <td v-if="isPdf" width="35%">
                温度：
                <span style="display: inline-block; width: 10%;">{{ form.shiytjwd }}</span>
                ℃；湿度：
                <span style="display: inline-block; width: 10%;">{{ form.shiytjsd }}</span>%RH
              </td>
              <td v-else width="35%">
                温度：
                <el-input :type="isPdf?'string':'number'" v-model="form.shiytjwd" class="height100" style="width: 15%" />℃；湿度：
                <el-input :type="isPdf?'string':'number'" v-model="form.shiytjsd" class="height100" style="width: 15%" />%RH
              </td>
          </tr>
          <tr>
            <td height="50" align="center" width="15%">
              <span style="width: 90px; display: inline-block">检测依据</span>
            </td>
            <td width="35%">
              <span v-if="isPdf">{{ form.jiancyj }}</span>
              <el-input v-else type="textarea" v-model="form.jiancyj" :rows="2" class="mark" @dblclick.native="showBsJiancyjView" readonly />
            </td>
            <td align="center" width="15%">
              <span style="width: 90px; display: inline-block">判定依据</span>
            </td>
            <td width="35%">
              <span v-if="isPdf">{{ form.pandyj }}</span>
              <el-input v-else type="textarea" v-model="form.pandyj" :rows="2" @dblclick.native="showBsJudgeBaseView" @focus="handleFocus('pandyj')" class="mark" />
            </td>
          </tr>
          <tr class="bottom-border">
            <td height="50" align="center">
              <div>主要仪器设备</div>
              <div>名称及编号</div>
            </td>
            <td colspan="3">
              <span v-if="isPdf">{{form.zhuyyqsbmcjbh}}</span>
              <el-input v-else type="textarea" :rows="2" v-model="form.zhuyyqsbmcjbh" class="height100 width100 mark" @dblclick.native="showBsInstrumentView" readonly></el-input>
            </td>
          </tr>
        </tbody>
      </table>
      <!-- .................................22222222222222222222222222222222............................................... -->
      <table height="616px" class="middle-table">
        <tbody>
          <tr trindex="0" width="100%" >
            <td width="15%" colspan="2" height="30">配合比编号</td>
            <td  colspan="5" height="30">
              <el-input v-model="form.peihbbh" />
            </td>
            <td width="15%" colspan="2" height="30">养护条件</td>
            <td width="22%" colspan="4" height="30">
              <el-input v-model="form.yanghtj" />
            </td>
          </tr>
          <tr trindex="1">
            <td  colspan="2" height="30">设计弹性模量</td>
            <td colspan="5" height="30">
              <el-input v-model="form.shejtxml" ></el-input>
            </td>
            <td  colspan="2" height="30">龄期(d)</td>
            <td  colspan="4" height="30">
              <el-input v-model="form.lingq" />
            </td>
          </tr>

          <tr trindex="2" width="100%" >
            <td  colspan="1" rowspan="4" width='7%'>棱柱体抗压强度</td>
            <td  colspan="1" width='7%'>编号</td>
            <td  colspan="2" width='15%'>试件尺寸(mm)</td>
            <td  colspan="2" width='15%'>极限荷载(kN)</td>
            <td  colspan="2">承压面积(m㎡)</td>
            <td  colspan="2" width='15%'>轴心抗压强度(MPa)</td>
            <td  colspan="1" width='7%'>换算系数</td>
            <td  colspan="2" width='15%'>轴心抗压强度平均值(MPa)</td>
          </tr>
          <tr trindex="3" width="100%" v-for="(item,index) of form.details" :key="index">
            <td  colspan="1" width='7%'>{{ index+1 }}</td>
            <td  colspan="2" width='15%'><el-input v-model="item.shijcc" /></td>
            <td  colspan="2" width='8%'><el-input v-model="item.jixhz" @blur="computeZxkyqd" /></td>
            <td  colspan="2"><el-input v-model="item.chengymj" @blur="computeZxkyqd"/></td>
            <td  colspan="2" width='15%'>{{item.zhouxkyqd}}</td>
            <td  colspan="1" v-if="index%3==0" rowspan="3" width='8%'>1.0</td>
            <td  colspan="2" v-if="index%3==0" rowspan="3" width='15%'>{{item.zhouxkyqdpj}}</td>
          </tr>
          <tr trindex="2" width="100%" >
            <td  colspan="1"  rowspan="5" width='7%'>棱柱体抗压强度弹性模量</td>
            <td  colspan="1" rowspan="2" width='7%'>编号</td>
            <td  colspan="1" rowspan="2" width='8%'>终荷载Fa(kN)</td>
            <td  colspan="1" rowspan="2" width='8%'>初荷载F0(kN)</td>
            <td  colspan="1" rowspan="2" width='7%'>测量标距(mm)</td>
            <td  colspan="1" rowspan="2">试件承压面积A(mm2)</td>
            <td  colspan="2" width='15%'>对中时</td>
            <td  colspan="2" width='15%'>测试时</td>
            <td  colspan="1" width='7%' rowspan="2">△n(0.001mm)</td>
            <td  colspan="1" rowspan="2" width='8%'>抗压弹性模量Ec(MPa)</td>
            <td  colspan="1" rowspan="2" width='8%'>抗压弹性模量平均值(MPa)</td>
          </tr>
          <tr>
            <td  colspan="1"  width='7%'>ε0左(0.001mm)</td>
            <td  colspan="1"  width='7%'>ε0右(0.001mm)</td>
            <td  colspan="1"  width='7%'>εa左(0.001mm)</td>
            <td  colspan="1"  width='7%'>εa右(0.001mm)</td>
          </tr>
          <tr trindex="3" width="100%" v-for="(item,index) of form.details" :key="index+5">
            <td  colspan="1" width='7%'>{{index+1}}</td>
            <td  colspan="1" width='7%'>{{item.zhonghz}}</td>
            <td  colspan="1" width='8%'><el-input v-model="item.chuhz" @blur="computeKytxml"/></td>
            <td  colspan="1"><el-input v-model="item.celbj" @blur="computeKytxml"/></td>
            <td  colspan="1" width='7%'><el-input v-model="item.shijcymj" @blur="computeKytxml"/></td>
            <td  colspan="1" width='7%'><el-input v-model="item.duizsz" @blur="computeKytxml"/></td>
            <td  colspan="1" width='7%'><el-input v-model="item.duizsy" @blur="computeKytxml"/></td>
            <td  colspan="1" width='8%'><el-input v-model="item.cessz" @blur="computeKytxml"/></td>
            <td  colspan="1"><el-input v-model="item.cessy" @blur="computeKytxml"/></td>
            <td  colspan="1" width='7%'>{{item.dertn}}</td>
            <td  colspan="1"  width='8%'>{{item.kangytxml}}</td>
            <td  colspan="1" v-if="index%3==0" rowspan="3" width='8%'>{{item.kangytxmlpjz}}</td>
          </tr>

          <tr trindex="2" width="100%" >
            <td  colspan="1" rowspan="4" width='7%'>弹性模量检测后抗压强度</td>
            <td  colspan="1" width='7%'>编号</td>
            <td  colspan="2" width='15%'>试件尺寸(mm)</td>
            <td  colspan="2" width='15%'>极限荷载(kN)</td>
            <td  colspan="2">承压面积(m㎡)</td>
            <td  colspan="2" width='15%'>轴心抗压强度(MPa)</td>
            <td  colspan="1" width='7%'>换算系数</td>
            <td  colspan="2" width='15%'>轴心抗压强度平均值(MPa)</td>
          </tr>
          <tr trindex="3" width="100%" v-for="(item,index) of form.details" :key="index+9">
            <td  colspan="1" width='7%'>{{index+1}}</td>
            <td  colspan="2" width='15%'><el-input v-model="item.shijcch" /></td>
            <td  colspan="2" width='8%'><el-input v-model="item.jixhzh" @blur="computeZxkyqdh" /></td>
            <td  colspan="2"><el-input v-model="item.chengymjh" @blur="computeZxkyqdh" /></td>
            <td  colspan="2" width='15%'>{{item.zhouxkyqdh}}</td>
            <td  colspan="1" v-if="index%3==0" rowspan="3" width='8%'>1.0</td>
            <td  colspan="2" v-if="index%3==0" rowspan="3" width='15%'>{{item.zhouxkyqdpjh}}</td>
          </tr>
        </tbody>
      </table>
      <!-- .....................................................33333333333333333................................................... -->
      <table height="50px" class="bottom-table">
          <tr>
            <td>
              <!-- @focus="handleFocus('fujsm')" -->
              <el-input type="textarea" :rows="2" v-model="fjsm" />
            </td>
          </tr>
        </table>
      </div>
      <!-- .................................44444444444............................................. -->
      <table height="22px" class="transparent">
        <tbody>
          <tr>
            <td width="10%" align="right">检测：</td>
            <td width="15%" align="left"></td>
            <td width="10%" align="right">记录：</td>
            <td width="15%" align="left"></td>
            <td width="10%" align="right">复核：</td>
            <td align="left" width="15%"></td>
            <td width="10%">日期：</td>
            <td align="left" width="15%"></td>
          </tr>
        </tbody>
      </table>
    </div>
    <bs-jiancyj-view ref="bsJiancyjViewRef" @select="selectJiancyj" :syType="syType"></bs-jiancyj-view>
    <bs-instrument-view ref="bsInstrumentViewRef" @select="selectInstrument"></bs-instrument-view>
    <bs-judge-base-view ref="bsJudgeBaseViewRef" @select="selectJudge" :syType="syType" />
    <bs-judge-base-edit-view ref="bsJudgeBaseEditViewRef" @submit="selectJudgeBaseEdit" :syType="syType" />
  </div>
</template>

<script>

import {getSnhntKytxmlBsInfo, } from "@/api/reportsnhnt/snhntKytxmlBsInfo";

import decimal from "@/utils/big-decimal";
import BsInstrumentView from "@/views/dept/bsInstrument/BsInstrumentView.vue";
import BsJiancyjView from '@/views/sycs/bsJiancyj/BsJiancyjView.vue';
import {computeBiQualification} from "@/api/sycs/biQualification";
import {emptyConvert} from "@/views/reportForms/utils";
import BsJudgeBaseView from "@/views/sycs/bsJudgeBase/BsJudgeBaseView.vue";
import BsJudgeBaseEditView from "@/views/sycs/bsJudgeBase/BsJudgeBaseEditView.vue";
export default {
  name: "bhw",
  components: {
    BsInstrumentView,
    BsJiancyjView,
    BsJudgeBaseView,
    BsJudgeBaseEditView,
  },
  data() {
    return {
      huansxs:1,
      lingq:undefined,
      quybw:null,
      huansxsoption:[{value:1,label:"1"},{value:1.35,label:"1.35"},],
      options:[{value:3,label:"3"},{value:7,label:"7"},{value:28,label:"28"},],
      jilbh:'',
      form: {
        shiyrq:'2024年03月09日',
        gongcbwyt:'',
        baogbh:'',
        jiancdwmc:'山东路桥集团试验检测中心有限公司泰安高速公路施工总承包项目工地试验室',
        totalPage:"",
        page:'',
        jiancyj:'',
        zhuyyqsbmcjbh:'',
        gongcmc:'汾阳至石楼高速公路',
        yangpmc: 'K39+820-K40+440原地面',
        yangpbh: 'JTG/T 3610-2019',
        laiysj: '2022年03月09日',
        yangpsl: '3kg',
        yangpzt: '完好无损',
      },
      twoTableData: {

      },
      threeTableData:{

      },
      fjsm: '附加声明：',
      dateText: '2024年05月10日',
      readonly: false
    };
  },
  props: {
    excelId: {
      type: [String, Number],
      default: () => ""
    },
    isPdf: {
      type: Boolean,
      default: () => false
    },
    syType: {
      type: [String, Number],
      default: () => ""
    }
  },
  watch:{

  },
  created () {
    this.getInfo();
  },
  methods: {
    // 获取详情
    getInfo () {
      if (!this.excelId) {
        return;
      }
      getSnhntKytxmlBsInfo(this.excelId).then((response) => {
        this.form = response.data;
      });
    },
    submitForm(){
      return this.form;
    },
    // 显示检测依据列表
  showBsJiancyjView () {
      this.$refs.bsJiancyjViewRef.init(this.form.jiancyjIds);
    },
    // 检测依据选择
    selectJiancyj (info) {
      // this.$set(this.form, 'jiancyj', info.label);
      this.form.jiancyj = info.label;
      this.form.jiancyjIds = info.ids;
    },
    // 仪器选择
    selectInstrument (info) {
      this.form.zhuyyqsbmcjbh = info.label;
      this.form.shebIds = info.ids;
    },
    // 显示仪器列表
    showBsInstrumentView () {
      this.$refs.bsInstrumentViewRef.init(this.form.shebIds);
    },

    // 显示判定依据列表
    showBsJudgeBaseView() {
      this.$refs.bsJudgeBaseViewRef.init(this.form.pandyjIds);
    },
    // 判断依据选择
    selectJudge(info) {
      if (!info || !info.label) {
        return;
      }
      if (!this.form.pandyj) {
        this.form.pandyj = info.label;
      } else {
        if (info && info.label) {
          this.form.pandyj += "、" + info.label;
        }
      }
      // 添加指标 info.list
      let keys = [];
      info.list.forEach((item) => {
       if (this.form.baDetailVos[item.refQualId] && this.form.baDetailVos[item.refQualId].jiancjg) {
          this.form.baDetailVos[item.refQualId].symbolValue = item.symbolValue;
          this.form.baDetailVos[item.refQualId].num1 = item.num1;
          this.form.baDetailVos[item.refQualId].num2 = item.num2;
          keys.push(item.refQualId);
        }
      });
      this.computeDetectionResult(keys);
    },
    // 计算检测结果
    computeDetectionResult(keys) {
      if (!keys || keys.length <= 0) {
        return;
      }
      const data = keys.map((key) => {
        const info = {
          ...this.form.baDetailVos[key],
          jiancjg: this.form.baDetailVos[key].jiancjg == "-" ? "" : this.form.baDetailVos[key].jiancjg
        };
        return info;
      });
      computeBiQualification(data).then((res) => {
        const returnData = res.data;
        returnData.forEach((item) => {
          if (!item.symbolValue && !item.num1 && !item.num2) {
            item.jiszb = "-";
          }
          item.jiancjg = item.jiancjg ? item.jiancjg : "-";
          this.form.baDetailVos[item.qualId] = item;
        });
      });
    },

    // 编辑单个技术指标后赋值
    selectJudgeBaseEdit(info) {
      if (info.qualId) {
        this.form.baDetailVos[info.qualId] = info;
      }
      this.computeDetectionResult([info.qualId]);
    },

    //计算轴心抗压强度
    computeZxkyqd(){
      if(this.form.details){
        let qdz = [];
        for(let item of this.form.details){
          if(item.jixhz && item.chengymj){
            item.zhouxkyqd = decimal.divide(item.jixhz,item.chengymj)
            qdz.push(item.zhouxkyqd);
          } else {
            item.zhouxkyqd = undefined;
          }
        }
        if(qdz && qdz.length>0){
          //求和
          let sum = 0;
          for(let i of qdz){
            sum = decimal.add(sum,i);
          }
          //平均值；
          this.form.details[0].zhouxkyqdpj = this.form.details[1].zhouxkyqdpj = this.form.details[2].zhouxkyqdpj = decimal.divide(sum,qdz.length);
          //终荷载
          this.form.details[0].zhonghz = this.form.details[1].zhonghz = this.form.details[2].zhonghz =
            decimal.divide(decimal.multiply(22.5,this.form.details[0].zhouxkyqdpj),qdz.length);
        }else{
          this.form.details[0].zhouxkyqdpj = this.form.details[1].zhouxkyqdpj = this.form.details[2].zhouxkyqdpj = undefined;
          this.form.details[0].zhonghz = this.form.details[1].zhonghz = this.form.details[2].zhonghz = undefined;
        }
      }
    },

    //计算抗压弹性模量
    computeKytxml(){
      let kytxml = [];
      for(let item of this.form.details){
        //计算deta n
        if(item.duizsz && item.duizsy && item.cessz && item.cessy){
          item.dertn = decimal.subtract(decimal.divide(decimal.add(item.cessz,item.cessy),2),decimal.divide(decimal.add(item.duizsz,item.duizsy),2))
        } else {
          item.dertn = undefined;
        }
        //计算抗压弹性模量；

        if(item.chuhz && item.celbj && item.shijcymj && item.zhonghz && item.dertn){
          item.kangytxml = decimal.multiply(decimal.divide(decimal.multiply(1000,decimal.subtract(item.zhonghz,item.chuhz)),item.shijcymj),
            decimal.divide(decimal.multiply(1000,item.celbj),item.dertn))
          kytxml.push(item.kangytxml);
        } else {
          item.kangytxml = undefined;
        }
      }
      //计算抗压弹性模量平均
      if(kytxml && kytxml.length>0){
        let sum = 0;
        for(let i of kytxml){
          sum = decimal.add(sum,i);
        }
        this.form.details[0].kangytxmlpjz = this.form.details[1].kangytxmlpjz =this.form.details[2].kangytxmlpjz = decimal.divide(sum,kytxml.length);
      } else {
        this.form.details[0].kangytxmlpjz = this.form.details[1].kangytxmlpjz =this.form.details[2].kangytxmlpjz = undefined;
      }
    },

    //计算弹性模量检测后抗压强度
    computeZxkyqdh(){
      if(this.form.details){
        let qdz = [];
        for(let item of this.form.details){
          if(item.jixhzh && item.chengymjh){
            item.zhouxkyqdh = decimal.divide(item.jixhzh,item.chengymjh)
            qdz.push(item.zhouxkyqdh);
          } else {
            item.zhouxkyqdh = undefined;
          }
        }
        if(qdz && qdz.length>0){
          //求和
          let sum = 0;
          for(let i of qdz){
            sum = decimal.add(sum,i);
          }
          //平均值；
          this.form.details[0].zhouxkyqdpjh = this.form.details[1].zhouxkyqdpjh = this.form.details[2].zhouxkyqdpjh = decimal.divide(sum,qdz.length);
        }else{
          this.form.details[0].zhouxkyqdpjh = this.form.details[1].zhouxkyqdpjh = this.form.details[2].zhouxkyqdpjh = undefined;
        }
      }
    },

  },
};
</script>

<style scoped lang="scss">
</style>
